import { IPSAppWF } from './ipsapp-wf';
import { IPSAppWFDE } from './ipsapp-wfde';
import { IPSAppWFUIAction } from './ipsapp-wfuiaction';
import { IPSAppWFVer } from './ipsapp-wfver';
import { IPSWorkflow } from '../../wf/ipsworkflow';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppWFImpl extends PSModelObjectImpl implements IPSAppWF {
  protected allpsappwfuiactions: IPSAppWFUIAction[] | null = null;

  getAllPSAppWFUIActions(): IPSAppWFUIAction[] | null {
    if (this.allpsappwfuiactions == null) {
      this.allpsappwfuiactions = this.fillChildListModel(this.M.getAllPSAppWFUIActions, 'app.wf.IPSAppWFUIAction') as IPSAppWFUIAction[];
    }
    return this.allpsappwfuiactions;
  }

  get allPSAppWFUIActions(): IPSAppWFUIAction[] | null {
    return this.getAllPSAppWFUIActions();
  }

  findPSAppWFUIAction(objKey: any): IPSAppWFUIAction | null {
    return this.getPSModel5('app.wf.IPSAppWFUIAction', this.getAllPSAppWFUIActions(), objKey) as IPSAppWFUIAction;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psappwfdes: IPSAppWFDE[] | null = null;

  getPSAppWFDEs(): IPSAppWFDE[] | null {
    if (this.psappwfdes == null) {
      this.psappwfdes = this.fillChildListModel(this.M.getPSAppWFDEs, 'app.wf.IPSAppWFDE') as IPSAppWFDE[];
    }
    return this.psappwfdes;
  }

  get psAppWFDEs(): IPSAppWFDE[] | null {
    return this.getPSAppWFDEs();
  }

  findPSAppWFDE(objKey: any): IPSAppWFDE | null {
    return this.getPSModel5('app.wf.IPSAppWFDE', this.getPSAppWFDEs(), objKey) as IPSAppWFDE;
  }

  protected psappwfvers: IPSAppWFVer[] | null = null;

  getPSAppWFVers(): IPSAppWFVer[] | null {
    if (this.psappwfvers == null) {
      this.psappwfvers = this.fillChildListModel(this.M.getPSAppWFVers, 'app.wf.IPSAppWFVer') as IPSAppWFVer[];
    }
    return this.psappwfvers;
  }

  get psAppWFVers(): IPSAppWFVer[] | null {
    return this.getPSAppWFVers();
  }

  findPSAppWFVer(objKey: any): IPSAppWFVer | null {
    return this.getPSModel5('app.wf.IPSAppWFVer', this.getPSAppWFVers(), objKey) as IPSAppWFVer;
  }

  protected psworkflow: IPSWorkflow | null = null;

  getPSWorkflow(): IPSWorkflow | null {
    if (this.psworkflow != null) return this.psworkflow;
    const value = this.M.getPSWorkflow;
    if (value == null) {
      return null;
    }
    this.psworkflow = this.getPSModel4('wf.IPSWorkflow', value, 'getPSWorkflow') as IPSWorkflow;
    return this.psworkflow;
  }

  get psWorkflow(): IPSWorkflow | null {
    return this.getPSWorkflow();
  }

  getPSWorkflowMust(): IPSWorkflow {
    const value = this.getPSWorkflow();
    if (value == null) {
      throw new Error('未指定工作流');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get hasPSAppWFVer(): boolean {
    return this.M.hasPSAppWFVer;
  }

  getHasPSAppWFVer(): boolean {
    return this.M.hasPSAppWFVer;
  }

  get cls(): string {
    return 'PSAppWFImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.wf.IPSAppWF') return true;
    return super.instanceof(cls);
  }
}
